package com.yisen.dasan.controller;

import com.alibaba.fastjson.JSONObject;
import com.yisen.dasan.dao.AnswerMapper;
import com.yisen.dasan.service.AnalyzeDataService;
import com.yisen.dasan.util.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/analyze")
public class AnalyzeDataController {
    @Autowired
    AnalyzeDataService analyzeDataService;
    @GetMapping("/radio")
    public Object redioAnalyze(@RequestParam("itemId") int itemId){
        Object result = analyzeDataService.redioAnalyze(itemId);

        return new ResultData(true, 200, "成功！", result);
    }
    @GetMapping("/gender")
    public Object genderAnalyze(@RequestParam("itemId") int itemId){
        Object result = analyzeDataService.genderAnalyze(itemId);

        return new ResultData(true, 200, "成功！", result);
    }
    @GetMapping("/multiple")
    public ResultData multipleAnalyze(@RequestParam("itemId") int itemId){
        List<Map> result= analyzeDataService.multipleAnalyze(itemId);
        return new ResultData(true, 200, "成功！", result);
    }
    @GetMapping("/total")
    public ResultData totalAnalyze(@RequestParam("formId") int formId){
        int[] count=analyzeDataService.totalAnalyze(formId);
        return new ResultData(true, 200, "成功！", count);
    }
    @GetMapping("/map")
    public ResultData mapAnalyze(@RequestParam("formId") int formId){
        List<Map> list=analyzeDataService.mapAnalyze(formId);
        return new ResultData(true, 200, "成功！", list);
    }
    @GetMapping("/indexAnalyze")
    public ResultData indexAnalyze(@RequestParam("formId") int formId){
        JSONObject jsonObject = analyzeDataService.indexAnalyze(formId);
        return new ResultData(true, 200, "请求成功！", jsonObject);
    }
}
